package com.example.Annocation.Configeration;

import com.example.Annocation.commons.Person;
import com.example.Annocation.commons.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description TODO
 * @Date 2024/5/14 15:45
 * @Created by houjunfeng
 */
public class ConfigerationTest {
    public static void main(String[] args) {
        //基于xml文件
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("application.xml");
        Person person = applicationContext.getBean(Person.class);
        System.out.println(person);

        //基于注解
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(StudentConfiguration.class);
        Student student = annotationConfigApplicationContext.getBean(Student.class);
        System.out.println(student+"s");

        String[] types = annotationConfigApplicationContext.getBeanNamesForType(Student.class);
        for(String type:types){
            System.out.println(type);
        }
    }
}
